package com.heima.article.feign;

import com.heima.apis.article.IArticleFeign;
import com.heima.article.service.ApAuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhangyan
 * @date 2021/4/25 17:59
 *
 * 其实是Controller,为了方便 直接实现了Feign接口
 */

@RestController
@RequestMapping("/api/v1/author")
public class ArticleFeign implements IArticleFeign {

    @Autowired
    private ApAuthorService apAuthorService;

    @Override
    @GetMapping("/findByUserId/{userId}")
    public ApAuthor findByUserId(@PathVariable("userId") Integer userId) {
        return apAuthorService.findByUserId(userId);
    }

    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody ApAuthor apAuthor) {
        return apAuthorService.insert(apAuthor);
    }
}
